package study.domain.security;

import java.io.Serializable;

import javax.annotation.Resource;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;

import study.service.user.UserService;

/**
 * Spring Security에서 사용할 역활 계층
 *
 * @author Barney Kim
 *
 * @see UserService#getRoleHierarchyString()
 */
@SuppressWarnings("rawtypes")
public class RoleHierarchyStrings implements Serializable, InitializingBean, FactoryBean {

	private static final long serialVersionUID = 2310880339819755917L;

	@Resource(name = "userService")
	private UserService userService;

	private String roleHierarchy;

	@Override
	public void afterPropertiesSet() throws Exception {
		roleHierarchy = userService.getRoleHierarchyString();
	}

	@Override
	public Object getObject() throws Exception {
		return roleHierarchy;
	}

	@Override
	public Class getObjectType() {
		return String.class;
	}

	@Override
	public boolean isSingleton() {
		return true;
	}
}
